package com.novell.sasl.client;

import java.util.Map;
import org.apache.harmony.javax.security.auth.callback.CallbackHandler;
import org.apache.harmony.javax.security.sasl.SaslClient;
import org.apache.harmony.javax.security.sasl.SaslException;

public class ExternalSaslClient
  implements SaslClient
{
  private String m_authorizationId = "";
  private String m_protocol = "";
  private String m_serverName = "";
  private Map m_props;
  private CallbackHandler m_cbh;
  private int m_state;
  private static final int STATE_INITIAL = 0;
  private static final int STATE_VALID_SERVER_RESPONSE = 1;
  private static final int STATE_INVALID_SERVER_RESPONSE = 2;
  private static final int STATE_DISPOSED = 3;

  public static SaslClient getClient(String paramString1, String paramString2, String paramString3, Map paramMap, CallbackHandler paramCallbackHandler)
  {
    return new ExternalSaslClient(paramString1, paramString2, paramString3, paramMap, paramCallbackHandler);
  }

  private ExternalSaslClient(String paramString1, String paramString2, String paramString3, Map paramMap, CallbackHandler paramCallbackHandler)
  {
    this.m_authorizationId = paramString1;
    this.m_protocol = paramString2;
    this.m_serverName = paramString3;
    this.m_props = paramMap;
    this.m_cbh = paramCallbackHandler;
    this.m_state = 0;
  }

  public boolean hasInitialResponse()
  {
    return false;
  }

  public boolean isComplete()
  {
    return (this.m_state == 1) || (this.m_state == 2) || (this.m_state == 3);
  }

  public byte[] unwrap(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws SaslException
  {
    throw new IllegalStateException("unwrap: QOP has neither integrity nor privacy>");
  }

  public byte[] wrap(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws SaslException
  {
    throw new IllegalStateException("wrap: QOP has neither integrity nor privacy>");
  }

  public Object getNegotiatedProperty(String paramString)
  {
    if (this.m_state != 1)
      throw new IllegalStateException("getNegotiatedProperty: authentication exchange not complete.");
    if ("javax.security.sasl.qop".equals(paramString))
      return "auth";
    return null;
  }

  public void dispose()
    throws SaslException
  {
    if (this.m_state != 3)
      this.m_state = 3;
  }

  public byte[] evaluateChallenge(byte[] paramArrayOfByte)
    throws SaslException
  {
    byte[] arrayOfByte = null;
    switch (this.m_state)
    {
    case 0:
      if (paramArrayOfByte.length != 0)
      {
        this.m_state = 2;
        throw new SaslException("Unexpected non-zero length response.");
      }
      this.m_state = 1;
      break;
    case 2:
      throw new SaslException("Authentication sequence is complete");
    case 3:
      throw new SaslException("Client has been disposed");
    case 1:
    default:
      throw new SaslException("Unknown client state.");
    }
    return arrayOfByte;
  }

  public String getMechanismName()
  {
    return "EXTERNAL";
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     com.novell.sasl.client.ExternalSaslClient
 * JD-Core Version:    0.6.1
 */